import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class SingleSliderPanel extends JPanel 
{
    private ValueHolder _colorHolder;
    private ColorPanel _colorp;
    private JSlider _theSlider;
    
    public SingleSliderPanel(ValueHolder holder,String colorMessage,ColorPanel cp)
    {
        _colorHolder = holder;
        _colorp = cp;
        this.setLayout(new GridLayout(0,1));
        this.add(new JLabel(colorMessage,JLabel.CENTER));
        _theSlider = new JSlider(JSlider.HORIZONTAL,0,255,0);
        _theSlider.setMajorTickSpacing(10);
        _theSlider.setMinorTickSpacing(2);
        _theSlider.setPaintTicks(true);
        _theSlider.setPaintLabels(true);
        _theSlider.addChangeListener(new SliderListener());
        this.add(_theSlider);
    }
    private class SliderListener implements ChangeListener
    {
        public void stateChanged(ChangeEvent e)
        {
            _colorHolder.setValue(_theSlider.getValue());
            _colorp.changeColor();
        }
    }
}
